import random

# 定义牌型
SUITS = ['♥', '♦', '♠', '♣']
RANKS = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2']
SPECIAL = ['小王', '大王']

class Card:
    def __init__(self, suit, rank):
        self.suit = suit  # 花色
        self.rank = rank  # 牌面

    def __str__(self):
        return f"{self.suit}{self.rank}"

# 生成一副牌
def create_deck():
    deck = [Card(suit, rank) for suit in SUITS for rank in RANKS]
    deck.extend([Card('', spec) for spec in SPECIAL])  # 添加大小王
    return deck

# 发牌（3人斗地主）
def deal_cards(deck):
    random.shuffle(deck)
    players = [[], [], []]  # 三个玩家
    for i in range(51):  # 每人17张
        players[i % 3].append(deck.pop())
    return players, deck[:3]  # 返回玩家手牌和底牌

# 示例运行
if __name__ == "__main__":
    deck = create_deck()
    players, remaining_cards = deal_cards(deck)

    print("玩家手牌：")
    for i, hand in enumerate(players):
        print(f"玩家{i+1}:", ' '.join(str(card) for card in sorted(hand, key=lambda x: RANKS.index(x.rank))))

    print("底牌:", ' '.join(str(card) for card in remaining_cards))
